package com.lalameow.researchstation.api.technology

import kotlinx.serialization.Serializable
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant
import net.minecraft.stat.Stat

/**
 * 液体资源
 */
@Suppress("UnstableApiUsage")
@Serializable
class FluidRequirement(override val resource: FluidResource) : TechnologyRequirement<FluidVariant> {
    override fun progressing() = Progressing(this)

    override fun construct(type: FluidVariant, count: Long) = FluidResource(type, count)

    class Progressing(
        private val requirement: FluidRequirement
    ) : TechnologyRequirement.Progressing<FluidVariant>,
        TechnologyRequirement<FluidVariant> by requirement {
        override var current: Long = 0

        override fun progressing() = this
    }
}

/**
 * 物品资源
 */
@Suppress("UnstableApiUsage")
@Serializable
class ItemRequirement(override val resource: ItemResource) : TechnologyRequirement<ItemVariant> {
    override fun progressing() = Progressing(this)

    override fun construct(type: ItemVariant, count: Long) = ItemResource(type, count)

    @Serializable
    class Progressing(
        private val requirement: ItemRequirement
    ) : TechnologyRequirement.Progressing<ItemVariant>,
        TechnologyRequirement<ItemVariant> by requirement {
        override var current: Long = 0

        override fun progressing() = this
    }
}

@Serializable
class PlayerStatRequirement(override val resource: StatResource) : TechnologyRequirement<Stat<*>> {
    override fun progressing() = Progressing(this)

    override fun construct(type: Stat<*>, count: Long) = StatResource(type, count)

    @Serializable
    class Progressing(
        private val requirement: PlayerStatRequirement
    ) : TechnologyRequirement.Progressing<Stat<*>>,
        TechnologyRequirement<Stat<*>> by requirement {
        override var current: Long = 0
        override fun progressing() = this
    }
}
